﻿using ShareCode.Dto.User;
using ShareCode.Dto;
using ShareCode.Entity.User;

namespace ClientDao.User
{
    public class UserAccountDal : BaseContainDateDal<UserAccountEntity>
    {
        public UserAccountDal()
        {
            Controller += "User/UserAccount";
        }

        public async Task<Stream> GetVerificationCode(int height, int width, string requestToken = "")
        {
            var imgstream = await GetStreamAsync($"validcode/{height}/{width}/{requestToken}");

            return imgstream;
        }
        public async Task<ResultDto<LoginReturnDto>> LoginByNameAndPsw(LoginByNameAndPswResqestDto loginByNameAndPsw)
        {
            var imgstream = await PostAsync<LoginByNameAndPswResqestDto, LoginReturnDto>($"LoginByNameAndPsw", loginByNameAndPsw);

            return imgstream;
        }

        public async Task<ResultDto<long>> Register(UserRegisterDto loginByNameAndPsw)
        {
            var imgstream = await PostAsync<UserRegisterDto, long>($"Register", loginByNameAndPsw);

            return imgstream;
        }
    }
}
